<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'task-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'tcode'); ?>
<?php 
echo $form->dropDownList($model,'tcode', $tcodeArr,array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>'index.php?r=task/fetchSubcode', //url to call
'update'=>'#Task_subcode', //selector to update
//'data'=>'js:javascript statement'
))); 
?>
		<?php echo $form->error($model,'tcode'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'subcode'); ?>
		<?php echo $form->dropDownList($model,'subcode',$subcodeArr,array('onchange'=>'fxl()')); ?>
		<?php echo $form->error($model,'subcode'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'task'); ?>
		<?php echo $form->textField($model,'task',array('size'=>60,'maxlength'=>255,'readonly'=>"readonly")); ?>
		<?php echo $form->error($model,'task'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'office'); ?>
		<?php echo $form->dropDownList($model,'office', Yii::app()->params['office']); ?>
		<?php echo $form->error($model,'office'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'taskdetail'); ?>
		<?php echo $form->textArea($model,'taskdetail',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'taskdetail'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'tco'); ?>
		<?php echo $form->textField($model,'tco',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'tco'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'sco'); ?>
		<?php echo $form->textField($model,'sco',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'sco'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'periodic'); ?>
		<?php echo $form->dropDownList($model,'periodic',array('O'=>'Once','S'=>'Shift','D'=>'Day','W'=>'Week','M'=>'Month','Y'=>'Year')); ?>
		<?php echo $form->error($model,'periodic'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'urgency'); ?>
        <?php echo $form->dropDownList($model,'urgency',array(2=>'Nomal',3=>'High',1=>'Low',4=>'Rush')); ?>
		<?php echo $form->error($model,'urgency'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'complete'); ?>
		<?php echo $form->textField($model,'complete'); ?>
		<?php echo $form->error($model,'complete'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'group'); ?>
		<?php echo $form->dropDownList($model,'group',array('M'=>'M','S'=>'S')); ?>
		<?php echo $form->error($model,'group'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'estart'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				'attribute' => 'estart',
				'model'=>$model,
				'language'=>'zh',
				'options' => array(
						'showAnim' => 'fold',
						'dateFormat' => 'yy-mm-dd',
				),
		));
		?>
		<?php echo $form->error($model,'estart'); ?>
	</div>	

	<div class="row">
		<?php echo $form->labelEx($model,'eend'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				'attribute' => 'eend',
				'model'=>$model,
				'language'=>'zh',
				'options' => array(
						'showAnim' => 'fold',
						'dateFormat' => 'yy-mm-dd',
				),
		));
		?>
		<?php echo $form->error($model,'eend'); ?>
	</div>
    
    <div class="row">
		<?php echo $form->labelEx($model,'rstart'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				'attribute' => 'rstart',
				'model'=>$model,
				'language'=>'zh',
				'options' => array(
						'showAnim' => 'fold',
						'dateFormat' => 'yy-mm-dd',
				),
		));
		?>
		<?php echo $form->error($model,'rstart'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'rend'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				'attribute' => 'rend',
				'model'=>$model,
				'language'=>'zh',
				'options' => array(
						'showAnim' => 'fold',
						'dateFormat' => 'yy-mm-dd',
				),
		));
		?>
		<?php echo $form->error($model,'rend'); ?>
	</div>

	<div class="row">

		<?php echo $form->labelEx($model,'status'); ?>
        <?php echo $form->dropDownList($model,'status',array('1'=>'Open','2'=>'Close')); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'follow_up_person'); ?>
		<?php echo $form->textField($model,'follow_up_person',array('size'=>20,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'follow_up_person'); ?>
	</div>
    <div class="row">
		<?php echo $form->labelEx($model,'follow_up_date'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
				'attribute' => 'follow_up_date',
				'model'=>$model,
				'language'=>'zh',
				'options' => array(
						'showAnim' => 'fold',
						'dateFormat' => 'yy-mm-dd',
				),
		));
		?>
		<?php echo $form->error($model,'rend'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'remark'); ?>
		<?php echo $form->textArea($model,'remark',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'remark'); ?>
	</div>
    
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
<script>
var fxl = function (){
    var data=document.getElementById('Task_subcode').value;
    $.post('<?php echo CHtml::normalizeUrl(array('/Task/fetchClassDes')); ?>',{'classid':data}, function (data) {
        var ret = $.parseJSON(data);
        if (ret != null && ret.success != null && ret.success) {
            document.getElementById('Task_task').value = ret.msg;
        }
	});
}
var taskDes = '<?=$taskDes?>';
if(taskDes!=''){
	 document.getElementById('Task_task').value = taskDes;
}
</script>